//
//  TGBaseModel.m
//  TongGuanLease
//
//  Created by 张奇 on 2022/4/13.
//

#import "TGBaseModel.h"

@implementation TGBaseModel

+(id)TGModelWithJSON:(id)json {
    NSDictionary *dict = [NSObject jsonToObject:json];
    if (dict && [dict isKindOfClass:[NSDictionary class]]) {
        NSInteger status = [dict[@"status"] intValue];
        NSString *msg = dict[@"msg"];
        NSString *className = NSStringFromClass(self);
        if (status == 200 && ![className isEqualToString:@"BaseModel"]) {
            id data = dict[@"data"];
            if (data && ![data isKindOfClass:[NSString class]]) {
                TGBaseModel * subCls = [self modelWithJSON:dict];
                subCls.status = status;
                subCls.msg = msg;
                return subCls;
            }else{
                TGBaseModel *cls  = [self modelWithJSON:json];
                return cls;
                NSLog(@"%@",data);
            }
        }else{
            TGBaseModel *cls  = [TGBaseModel modelWithJSON:json];
            return cls;
        }
    }
    return nil;
}

-(BOOL)isSuccess {
    return YES;
}

@end
